//package com.szholly.data.mongodb;
//
//import java.io.StringReader;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.regex.Pattern;
//
//import com.szholly.data.general.GlobalParameter;
//import com.mongodb.BasicDBList;
//import com.mongodb.BasicDBObject;
//import com.mongodb.DBObject;
//
//import net.sf.jsqlparser.JSQLParserException;
//import net.sf.jsqlparser.expression.*;
//import net.sf.jsqlparser.expression.operators.arithmetic.*;
//import net.sf.jsqlparser.expression.operators.conditional.*;
//import net.sf.jsqlparser.expression.operators.relational.*;
//import net.sf.jsqlparser.parser.CCJSqlParserManager;
//import net.sf.jsqlparser.schema.Column;
//import net.sf.jsqlparser.schema.Table;
//import net.sf.jsqlparser.statement.Statement;
//import net.sf.jsqlparser.statement.create.table.CreateTable;
//import net.sf.jsqlparser.statement.delete.Delete;
//import net.sf.jsqlparser.statement.drop.Drop;
//import net.sf.jsqlparser.statement.insert.Insert;
//import net.sf.jsqlparser.statement.select.*;
//import net.sf.jsqlparser.statement.update.Update;
//
///**
// * 定义SQL解释器
// */
///**
// * @author CHENXU
// *
// */
//public class SqlParserUtils {
//
//	private static CCJSqlParserManager parserManager = new CCJSqlParserManager();
//
//	/**
//	 * 解释SQL语句
//	 *
//	 * @param sql
//	 * @return
//	 * @throws JSQLParserException
//	 */
//	public static SqlParserResult parserSql(String sql, GlobalParameter[] para)
//			throws JSQLParserException {
//		SqlParserResult result = new SqlParserResult();
//		result.sqlType = SqlType.No;
//		Statement statement = parserManager.parse(new StringReader(sql));
//		if (statement instanceof Select) {
//			result.sqlType = SqlType.Select;
//			parserSelectSql((Select) statement, result, para);
//		} else if (statement instanceof Insert) {
//			result.sqlType = SqlType.Insert;
//			parserInsertSql((Insert) statement, result, para);
//		} else if (statement instanceof Update) {
//			result.sqlType = SqlType.Update;
//			parserUpdateSql((Update) statement, result, para);
//		} else if (statement instanceof Delete) {
//			result.sqlType = SqlType.Delete;
//			parserDeleteSql((Delete) statement, result, para);
//		} else if (statement instanceof CreateTable) {
//			result.sqlType = SqlType.Create;
//			parserCreateTableSql((CreateTable) statement, result);
//		} else if (statement instanceof Drop) {
//			result.sqlType = SqlType.Drop;
//			parserDropSql((Drop) statement, result);
//		}
//		return result;
//	}
//
//	/**
//	 * 解释创建表语句
//	 *
//	 * @param createTableStatement
//	 * @param result
//	 */
//	private static void parserCreateTableSql(CreateTable createTableStatement,
//			SqlParserResult result) {
//		result.tableName = createTableStatement.getTable().getName();
//	}
//
//	/**
//	 * 解释删除表语句
//	 *
//	 * @param dropStatement
//	 * @param result
//	 */
//	private static void parserDropSql(Drop dropStatement, SqlParserResult result) {
//		result.tableName = dropStatement.getName();
//	}
//
//	/**
//	 * 解释删除语句
//	 *
//	 * @param deleteStatement
//	 * @param result
//	 */
//	private static void parserDeleteSql(Delete deleteStatement,
//			SqlParserResult result, GlobalParameter[] para) {
//		result.tableName = deleteStatement.getTable().getName();
//		ParserPara parserIndex = new ParserPara();
//		parserIndex.paraIndex = 0;
//		result.whereObject = (DBObject) parserWhere(deleteStatement.getWhere(),
//				para, parserIndex);
//	}
//
//	/**
//	 * 解释插入语句
//	 *
//	 * @param insertStatement
//	 * @param result
//	 */
//	@SuppressWarnings("rawtypes")
//	private static void parserInsertSql(Insert insertStatement,
//			SqlParserResult result, GlobalParameter[] para) {
//
//		result.tableName = insertStatement.getTable().getName();
//		ExpressionList valueList = (ExpressionList) insertStatement
//				.getItemsList();
//		List expressionList = valueList.getExpressions();
//		List columnsList = insertStatement.getColumns();
//
//		DBObject allCondition = new BasicDBObject();
//		ParserPara parserIndex = new ParserPara();
//		parserIndex.paraIndex = 0;
//		for (int i = 0; i < columnsList.size(); i++) {
//			Column column = (Column) columnsList.get(i);
//			String fieldName = column.getColumnName();
//			Expression expression = (Expression) expressionList.get(i);
//			Object value = parserValueExpression(expression, para, parserIndex);
//			allCondition.put(fieldName, value);
//		}
//		result.insertValuesObject = allCondition;
//	}
//
//	/**
//	 * 解释更新语句
//	 *
//	 * @param updateStatement
//	 * @param result
//	 */
//	@SuppressWarnings("rawtypes")
//	private static void parserUpdateSql(Update updateStatement,
//			SqlParserResult result, GlobalParameter[] para) {
//
//		ParserPara parserIndex = new ParserPara();
//		parserIndex.paraIndex = 0;
//		result.tableName = updateStatement.getTable().getName();
//		List columnsList = updateStatement.getColumns();
//		List setList = updateStatement.getExpressions();
//
//		DBObject setCondition = new BasicDBObject();
//		DBObject incCondition = new BasicDBObject();
//
//		for (int i = 0; i < columnsList.size(); i++) {
//			Column column = (Column) columnsList.get(i);
//			String fieldName = column.getColumnName();
//			Expression expression = (Expression) setList.get(i);
//			parserSets(fieldName, expression, setCondition, incCondition, para,
//					parserIndex);
//		}
//
//		DBObject allCondition = new BasicDBObject();
//		allCondition.put("$set", setCondition);
//		allCondition.put("$inc", incCondition);
//
//		result.whereObject = (DBObject) parserWhere(updateStatement.getWhere(),
//				para, parserIndex);
//		result.setObject = allCondition;
//	}
//
//	/**
//	 * 解释set表达式
//	 *
//	 * @param whereExpression
//	 * @param whereObject
//	 */
//	private static void parserSets(String fieldName,
//			Expression whereExpression, DBObject setCondition,
//			DBObject incCondition, GlobalParameter[] para, ParserPara paraIndex) {
//		if (whereExpression instanceof DateValue) { // 值表达式——日期值
//			setCondition.put(fieldName,
//					((DateValue) whereExpression).getValue());
//		} else if (whereExpression instanceof DoubleValue) {
//			setCondition.put(fieldName,
//					((DoubleValue) whereExpression).getValue());
//		} else if (whereExpression instanceof LongValue) {
//			setCondition.put(fieldName,
//					((LongValue) whereExpression).getValue());
//		} else if (whereExpression instanceof NullValue) {
//			setCondition.put(fieldName, null);
//		} else if (whereExpression instanceof StringValue) {
//			setCondition.put(fieldName,
//					((StringValue) whereExpression).getValue());
//		} else if (whereExpression instanceof TimestampValue) {
//			setCondition.put(fieldName,
//					((TimestampValue) whereExpression).getValue());
//		} else if (whereExpression instanceof TimeValue) {
//			setCondition.put(fieldName,
//					((TimeValue) whereExpression).getValue());
//		} else if (whereExpression instanceof Addition) { // 计算符 —— 加
//			Addition addition = (Addition) whereExpression;
//			if (!(addition.getLeftExpression() instanceof Column)) {
//				throw new RuntimeException("当前NoSQL解释set表达式错误！在加号前应该为列名称！");
//			}
//			String setFieldName = ((Column) addition.getLeftExpression())
//					.getColumnName();
//			Object fieldValue = parserValueExpression(
//					addition.getRightExpression(), para, paraIndex);
//			incCondition.put(setFieldName, fieldValue);
//		} else if (whereExpression instanceof Division) { // 除
//			throw new RuntimeException("当前NoSQL解释set表达式中不能包括/操作符！");
//		} else if (whereExpression instanceof Multiplication) { // 乘
//			throw new RuntimeException("当前NoSQL解释set表达式中不能包括*操作符！");
//		} else if (whereExpression instanceof Subtraction) { // 减
//			throw new RuntimeException("当前NoSQL解释set表达式中不能包括-操作符！");
//		} else if (whereExpression instanceof Column) {
//			throw new RuntimeException("当前NoSQL解释set表达式错误！");
//		} else if (whereExpression instanceof JdbcParameter) {
//			if (para == null || paraIndex.paraIndex >= para.length) {
//				throw new RuntimeException("当前NoSQL解释错误，参数为空或数量不够！");
//			}
//			GlobalParameter item = para[paraIndex.paraIndex];
//			paraIndex.paraIndex++;
//			setCondition.put(fieldName, item.getParaValue());
//		} else if (whereExpression instanceof Function) { // 列表达式——函数
//			throw new RuntimeException("当前NoSQL解释不支持set中包含函数表达式！");
//		} else if (whereExpression instanceof BitwiseAnd) { // &
//			throw new RuntimeException("当前NoSQL解释不支持set中包含&计算符！");
//		} else if (whereExpression instanceof BitwiseOr) { // |
//			throw new RuntimeException("当前NoSQL解释不支持set中包含|计算符！");
//		} else if (whereExpression instanceof BitwiseXor) { // ^
//			throw new RuntimeException("当前NoSQL解释不支持set中包含^计算符！");
//		} else if (whereExpression instanceof Concat) { // ||
//			throw new RuntimeException("当前NoSQL解释不支持set中包含||计算符！");
//		} else if (whereExpression instanceof EqualsTo) { // 对比操作符 —— =
//			throw new RuntimeException("当前NoSQL解释不支持set中包含=计算符！");
//		} else if (whereExpression instanceof NotEqualsTo) { // !=
//			throw new RuntimeException("当前NoSQL解释不支持set中包含<>计算符！");
//		} else if (whereExpression instanceof GreaterThan) { // >
//			throw new RuntimeException("当前NoSQL解释不支持set中包含>计算符！");
//		} else if (whereExpression instanceof GreaterThanEquals) { // >=
//			throw new RuntimeException("当前NoSQL解释不支持set中包含>=计算符！");
//		} else if (whereExpression instanceof MinorThan) { // <
//			throw new RuntimeException("当前NoSQL解释不支持set中包含<计算符！");
//		} else if (whereExpression instanceof MinorThanEquals) { // <=
//			throw new RuntimeException("当前NoSQL解释不支持set中包含<=计算符！");
//		} else if (whereExpression instanceof InExpression) { // in
//			throw new RuntimeException("当前NoSQL解释不支持set中包含in操作符！");
//		} else if (whereExpression instanceof IsNullExpression) { // is null
//			throw new RuntimeException("当前NoSQL解释不支持set中包含is null操作符！");
//		} else if (whereExpression instanceof LikeExpression) { // like
//			throw new RuntimeException("当前NoSQL解释不支持set中包含like操作符！");
//		} else if (whereExpression instanceof Between) { // between
//			throw new RuntimeException("当前NoSQL解释不支持Between表达式！");
//		} else if (whereExpression instanceof ExistsExpression) {
//			throw new RuntimeException("当前NoSQL解释不支持Exists表达式！");
//		} else if (whereExpression instanceof Matches) {
//			throw new RuntimeException("当前NoSQL解释不支持Exists表达式！");
//		} else if (whereExpression instanceof InverseExpression) { // 复杂表达式
//			throw new RuntimeException("当前NoSQL解释不支持InverseExpression表达式！");
//		} else if (whereExpression instanceof AllComparisonExpression) {
//			throw new RuntimeException(
//					"当前NoSQL解释不支持AllComparisonExpression表达式！");
//		} else if (whereExpression instanceof AnyComparisonExpression) {
//			throw new RuntimeException(
//					"当前NoSQL解释不支持AnyComparisonExpression表达式！");
//		} else if (whereExpression instanceof CaseExpression) {
//			throw new RuntimeException("当前NoSQL解释不支持CaseExpression表达式！");
//		} else if (whereExpression instanceof WhenClause) {
//			throw new RuntimeException("当前NoSQL解释不支持WhenClause表达式！");
//		} else if (whereExpression instanceof Parenthesis) { // 逻辑表达式——括号
//			throw new RuntimeException("当前NoSQL解释Sets中不支持括号表达式！");
//		} else if (whereExpression instanceof AndExpression) { // and
//			throw new RuntimeException("当前NoSQL解释Sets中不支持and表达式！");
//		} else if (whereExpression instanceof OrExpression) { // or
//			throw new RuntimeException("当前NoSQL解释Sets中不支持or表达式！");
//		} else {
//			throw new RuntimeException("当前NoSQL解释不支持当前表达式！");
//		}
//	}
//
//	/**
//	 * 解释value表达式
//	 *
//	 * @param whereExpression
//	 */
//	private static Object parserValueExpression(Expression whereExpression,
//			GlobalParameter[] para, ParserPara paraIndex) {
//		if (whereExpression instanceof DateValue) { // 值表达式——日期值
//			return ((DateValue) whereExpression).getValue();
//		} else if (whereExpression instanceof DoubleValue) {
//			return ((DoubleValue) whereExpression).getValue();
//		} else if (whereExpression instanceof LongValue) {
//			return ((LongValue) whereExpression).getValue();
//		} else if (whereExpression instanceof JdbcParameter) {
//			if (para == null || paraIndex.paraIndex >= para.length) {
//				throw new RuntimeException("当前NoSQL解释错误，参数为空或数量不够！");
//			}
//			GlobalParameter item = para[paraIndex.paraIndex];
//			paraIndex.paraIndex++;
//			return item.getParaValue();
//		} else if (whereExpression instanceof NullValue) {
//			return null;
//		} else if (whereExpression instanceof StringValue) {
//			return ((StringValue) whereExpression).getValue();
//		} else if (whereExpression instanceof TimestampValue) {
//			return ((TimestampValue) whereExpression).getValue();
//		} else if (whereExpression instanceof TimeValue) {
//			return ((TimeValue) whereExpression).getValue();
//		} else {
//			throw new RuntimeException("当前NoSQL解释错误！set表达式的右边应该为值表达式！");
//		}
//	}
//
//	/**
//	 * 解释查询语句
//	 *
//	 * @param selectStatement
//	 * @param result
//	 */
//	@SuppressWarnings("rawtypes")
//	private static void parserSelectSql(Select selectStatement,
//			SqlParserResult result, GlobalParameter[] para) {
//		List<String> fiels = new ArrayList<String>();
//		String tableName = "";
//		DBObject orderByObject = new BasicDBObject();
//		List<String> groupBy = new ArrayList<String>();
//		boolean hasFunctionField=false;
//
//		// 第一步，处理简单SQL，除where和order by
//		SelectBody selectBody = selectStatement.getSelectBody();
//		if (selectBody instanceof Union) {
//			throw new RuntimeException("当前NoSQL解释不支持Union操作符！");
//		}
//		PlainSelect plainSelect = (PlainSelect) selectBody;
//		List joins = plainSelect.getJoins();
//		if (joins != null) {
//			throw new RuntimeException("当前NoSQL解释不支持join操作！");
//		}
//
//		FromItem fromItem = plainSelect.getFromItem();
//		if (!(fromItem instanceof Table)) {
//			throw new RuntimeException("当前NoSQL解释不支持多表操作！");
//		}
//		tableName = ((Table) fromItem).getName();
//
//		Limit limit = plainSelect.getLimit();
//		if (limit != null) {
//			throw new RuntimeException("当前NoSQL解释不支持Limit操作符！");
//		}
//
//		Top top = plainSelect.getTop();
//		if (top != null) {
//			throw new RuntimeException("当前NoSQL解释不支持Top操作符！");
//		}
//
//		Distinct distinct = plainSelect.getDistinct();
//		if (distinct != null) {
//			throw new RuntimeException("当前NoSQL解释不支持Distinct操作符！");
//		}
//
//		List selectItems = plainSelect.getSelectItems();
//		for (Object selectItem : selectItems) {
//			if (selectItem instanceof SelectExpressionItem) {
//				Expression expression = ((SelectExpressionItem) selectItem)
//						.getExpression();
//				if (expression instanceof Column) {
//					String columnName = ((Column) expression).getColumnName();
//					fiels.add(columnName);
//				} else if (expression instanceof Function) {
//					Function functionExpression = (Function) expression;
//					if(hasFunctionField){
//						throw new RuntimeException("当前NoSQL解释不支持多函数列！");
//					}
//
//					String functionFieldName = functionExpression.getName();
//					functionFieldName = functionFieldName.toUpperCase().trim();
//					if(functionFieldName.equals("MAX")
//							|| functionFieldName.equals("MIN")
//							|| functionFieldName.equals("SUM")
//							|| functionFieldName.equals("COUNT")){
//						ExpressionList list = functionExpression.getParameters();
//						if(list==null
//								|| list.getExpressions()==null
//								|| list.getExpressions().size()!=1
//								|| !(list.getExpressions().get(0) instanceof Column)){
//							throw new RuntimeException("当前NoSQL解释不支持max,min,sum,count函数下指定的参数！");
//						}
//						String functionPara = ((Column) list.getExpressions().get(0)).getColumnName();
//						functionFieldName+=","+functionPara;
//						fiels.add(functionFieldName);
//						hasFunctionField=true;
//					}else{
//						throw new RuntimeException("当前NoSQL解释不支持max,min,sum,count之外的函数列！");
//					}
//				} else {
//					throw new RuntimeException("当前NoSQL解释不支持复杂查询列！");
//				}
//			} else if (selectItem instanceof AllColumns) {
//				fiels.add("*");
//			} else if (selectItem instanceof AllTableColumns) {
//				fiels.add("*");
//			}
//		}
//
//		List groupByColumns = plainSelect.getGroupByColumnReferences();
//		if (groupByColumns != null && groupByColumns.size() > 0) {
//			for (Object groupByColumn : groupByColumns) {
//				if (!(groupByColumn instanceof Column)) {
//					throw new RuntimeException("当前NoSQL解释不支持当前的Group By语句！");
//				}
//				String groupByItem = ((Column) groupByColumn).getColumnName();
//				groupBy.add(groupByItem);
//			}
//		}
//
//		List orderByList = plainSelect.getOrderByElements();
//		if (orderByList != null && orderByList.size() > 0) {
//			for (Object orderByItem : orderByList) {
//				OrderByElement orderByElement = (OrderByElement) orderByItem;
//				String orderFieldName = ((Column) orderByElement
//						.getExpression()).getColumnName();
//				if (orderByElement.isAsc()) {
//					orderByObject.put(orderFieldName, 1);
//				} else {
//					orderByObject.put(orderFieldName, -1);
//				}
//			}
//		}
//
//		// 处理where条件
//		ParserPara paraIndex = new ParserPara();
//		paraIndex.paraIndex = 0;
//		Expression whereExpression = plainSelect.getWhere();
//		DBObject whereObject = null;
//		if(whereExpression!=null){
//			whereObject = (DBObject) parserWhere(whereExpression, para, paraIndex);
//		}
//
//		result.selectFiels = fiels;
//		result.tableName = tableName;
//		result.whereObject = whereObject;
//		result.orderByObject = orderByObject;
//		result.groupBy = groupBy;
//		result.hasFunctionSelectField=hasFunctionField;
//	}
//
//	/**
//	 * 解释where表达式
//	 *
//	 * @param whereExpression
//	 * @param whereObject
//	 */
//	@SuppressWarnings("rawtypes")
//	private static Object parserWhere(Expression whereExpression,
//			GlobalParameter[] para, ParserPara paraIndex) {
//		if (whereExpression instanceof Parenthesis) { // 逻辑表达式——括号
//			Parenthesis parenthesis = (Parenthesis) whereExpression;
//			return parserWhere(parenthesis.getExpression(), para, paraIndex);
//		} else if (whereExpression instanceof AndExpression) { // and
//			AndExpression andExpression = (AndExpression) whereExpression;
//			Object left = parserWhere(andExpression.getLeftExpression(), para,
//					paraIndex);
//			Object righ = parserWhere(andExpression.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBList values = new BasicDBList();
//			values.add((BasicDBObject) left);
//			values.add((BasicDBObject) righ);
//			DBObject queryCondition = new BasicDBObject();
//			queryCondition.put("$and", values);
//			return queryCondition;
//		} else if (whereExpression instanceof OrExpression) { // or
//			OrExpression andExpression = (OrExpression) whereExpression;
//			Object left = parserWhere(andExpression.getLeftExpression(), para,
//					paraIndex);
//			Object righ = parserWhere(andExpression.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBList values = new BasicDBList();
//			values.add((BasicDBObject) left);
//			values.add((BasicDBObject) righ);
//			DBObject queryCondition = new BasicDBObject();
//			queryCondition.put("$or", values);
//			return queryCondition;
//		} else if (whereExpression instanceof DateValue) { // 值表达式——日期值
//			return ((DateValue) whereExpression).getValue();
//		} else if (whereExpression instanceof DoubleValue) {
//			return ((DoubleValue) whereExpression).getValue();
//		} else if (whereExpression instanceof LongValue) {
//			return ((LongValue) whereExpression).getValue();
//		} else if (whereExpression instanceof JdbcParameter) {
//			if (para == null || paraIndex.paraIndex >= para.length) {
//				throw new RuntimeException("当前NoSQL解释错误，参数为空或数量不够！");
//			}
//			GlobalParameter item = para[paraIndex.paraIndex];
//			paraIndex.paraIndex++;
//			return item.getParaValue();
//		} else if (whereExpression instanceof NullValue) {
//			return null;
//		} else if (whereExpression instanceof StringValue) {
//			return ((StringValue) whereExpression).getValue();
//		} else if (whereExpression instanceof TimestampValue) {
//			return ((TimestampValue) whereExpression).getValue();
//		} else if (whereExpression instanceof TimeValue) {
//			return ((TimeValue) whereExpression).getValue();
//		} else if (whereExpression instanceof Function) { // 列表达式——函数
//			throw new RuntimeException("当前NoSQL解释不支持where中包含函数表达式！");
//		} else if (whereExpression instanceof Column) {
//			return ((Column) whereExpression).getColumnName();
//		} else if (whereExpression instanceof Addition) { // 计算符 —— 加
//			throw new RuntimeException("当前NoSQL解释不支持+计算符！");
//		} else if (whereExpression instanceof Division) { // 除
//			throw new RuntimeException("当前NoSQL解释不支持/计算符！");
//		} else if (whereExpression instanceof Multiplication) { // 乘
//			throw new RuntimeException("当前NoSQL解释不支持*计算符！");
//		} else if (whereExpression instanceof Subtraction) { // 减
//			throw new RuntimeException("当前NoSQL解释不支持-计算符！");
//		} else if (whereExpression instanceof BitwiseAnd) { // &
//			throw new RuntimeException("当前NoSQL解释不支持&计算符！");
//		} else if (whereExpression instanceof BitwiseOr) { // |
//			throw new RuntimeException("当前NoSQL解释不支持|计算符！");
//		} else if (whereExpression instanceof BitwiseXor) { // ^
//			throw new RuntimeException("当前NoSQL解释不支持^计算符！");
//		} else if (whereExpression instanceof Concat) { // ||
//			throw new RuntimeException("当前NoSQL解释不支持||计算符！");
//		} else if (whereExpression instanceof EqualsTo) { // 对比操作符 —— =
//			EqualsTo addition = (EqualsTo) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			DBObject queryCondition = new BasicDBObject();
//			queryCondition.put(cloumName.toString(), value);
//			return queryCondition;
//		} else if (whereExpression instanceof NotEqualsTo) { // !=
//			NotEqualsTo addition = (NotEqualsTo) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBObject v = new BasicDBObject("$ne", value);
//			BasicDBObject result = new BasicDBObject(cloumName.toString(), v);
//			return result;
//		} else if (whereExpression instanceof GreaterThan) { // >
//			GreaterThan addition = (GreaterThan) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBObject v = new BasicDBObject("$gt", value);
//			BasicDBObject result = new BasicDBObject(cloumName.toString(), v);
//			return result;
//		} else if (whereExpression instanceof GreaterThanEquals) { // >=
//			GreaterThanEquals addition = (GreaterThanEquals) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBObject v = new BasicDBObject("$gte", value);
//			BasicDBObject result = new BasicDBObject(cloumName.toString(), v);
//			return result;
//		} else if (whereExpression instanceof MinorThan) { // <
//			MinorThan addition = (MinorThan) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBObject v = new BasicDBObject("$lt", value);
//			BasicDBObject result = new BasicDBObject(cloumName.toString(), v);
//			return result;
//		} else if (whereExpression instanceof MinorThanEquals) { // <=
//			MinorThanEquals addition = (MinorThanEquals) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object value = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//
//			BasicDBObject v = new BasicDBObject("$lte", value);
//			BasicDBObject result = new BasicDBObject(cloumName.toString(), v);
//			return result;
//		} else if (whereExpression instanceof InExpression) { // in
//			InExpression addition = (InExpression) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			ExpressionList list = (ExpressionList) addition.getItemsList();
//			List expressionList = list.getExpressions();
//			BasicDBList values = new BasicDBList();
//			for (Object item : expressionList) {
//				values.add(parserWhere((Expression) item, para, paraIndex));
//			}
//			BasicDBObject queryCondition = new BasicDBObject();
//			if (addition.isNot()) {
//				queryCondition.put(cloumName.toString(), new BasicDBObject(
//						"$nin", values));
//			} else {
//				queryCondition.put(cloumName.toString(), new BasicDBObject(
//						"$in", values));
//			}
//			return queryCondition;
//		} else if (whereExpression instanceof IsNullExpression) { // is null
//			IsNullExpression addition = (IsNullExpression) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			if (addition.isNot()) {
//				BasicDBObject v = new BasicDBObject("$ne", null);
//				BasicDBObject result = new BasicDBObject(cloumName.toString(),
//						v);
//				return result;
//			} else {
//				DBObject queryCondition = new BasicDBObject();
//				queryCondition.put(cloumName.toString(), null);
//				return queryCondition;
//			}
//		} else if (whereExpression instanceof LikeExpression) { // like
//			LikeExpression addition = (LikeExpression) whereExpression;
//			Object cloumName = parserWhere(addition.getLeftExpression(), para,
//					paraIndex);
//			Object content = parserWhere(addition.getRightExpression(), para,
//					paraIndex);
//			String contentString = content.toString();
//			contentString = contentString.replace("*", "").replace("?", "")
//					.replace("%", "");
//			BasicDBObject dbo = new BasicDBObject();
//			Pattern pattern = Pattern.compile("^.*" + contentString + ".*$",
//					Pattern.CASE_INSENSITIVE);
//			dbo.put(cloumName.toString(), pattern);
//			return dbo;
//		} else if (whereExpression instanceof Between) { // between
//			throw new RuntimeException("当前NoSQL解释不支持Between表达式！");
//		} else if (whereExpression instanceof ExistsExpression) {
//			throw new RuntimeException("当前NoSQL解释不支持Exists表达式！");
//		} else if (whereExpression instanceof Matches) {
//			throw new RuntimeException("当前NoSQL解释不支持Exists表达式！");
//		} else if (whereExpression instanceof InverseExpression) { // 复杂表达式
//			throw new RuntimeException("当前NoSQL解释不支持InverseExpression表达式！");
//		} else if (whereExpression instanceof AllComparisonExpression) {
//			throw new RuntimeException(
//					"当前NoSQL解释不支持AllComparisonExpression表达式！");
//		} else if (whereExpression instanceof AnyComparisonExpression) {
//			throw new RuntimeException(
//					"当前NoSQL解释不支持AnyComparisonExpression表达式！");
//		} else if (whereExpression instanceof CaseExpression) {
//			throw new RuntimeException("当前NoSQL解释不支持CaseExpression表达式！");
//		} else if (whereExpression instanceof WhenClause) {
//			throw new RuntimeException("当前NoSQL解释不支持WhenClause表达式！");
//		} else {
//			throw new RuntimeException("当前NoSQL解释不支持当前表达式！");
//		}
//	}
//}
